docs: Add sample code - #91
Conversation
There was a problem hiding this comment.
[q/req] Why is the path sample-code/src/sample_code? And underscore is preferred to better align with the naming conventions used by other folders.
There was a problem hiding this comment.
This is the standard modern path convention in Python (src layout). In this case, the flat layout should also work fine and is better/more aligned with the rest. I'll switch to that.
Regarding hyphenation: it's aligned in this regard that the low level folder names (which contains the source files) use underscores and only the outermost folder (with the project name) is hyphenated (like ai-sdk-python).
But we can also use sample_code/sample_code/example.py if that's preferred.
There was a problem hiding this comment.
Maybe examples/sample_code/...? Similar to https://github.com/pallets/flask/tree/main/examples
There can be later examples/tutorial/..., examples/langchain_agent/...
Also we never release these packages, should we remove the license file in the folder?
There was a problem hiding this comment.
We can remove the license file.
In your flask example there is one more layer of indirection: examples/javascript/js_example
For us we currently have: sample-code/sample_code where the outer dir contains already pyproject.toml like the javascript folder in flask.
So we could have examples/sample-code/sample_code... but I guess you still would want to change the name of the middle folder?
|
Another thing to note: I'm currently using a .env file for config that's supposed to lie in the |
Probably I missed it since I am a python sdk newbie. But why is there a .env already at repo root? In JS and Java, we just put .env in sample code and smoke test packages only as these are the only apps that need the credential? |
This PR adds example code that showcases usage of the SDK by exposing HTTP endpoints via a FastAPI application. Similar sample code exists for the other two AI SDKs.
This is a draft PR. The architecture/integration of the sample code may be up to discussion and more features should be added.
Currently, examples are included for the following services:
The following additions are planned:
Open things/questions up for discussion:
sample_codepackage be part of the root workspace? This is how it is currently proposed. It would be useful for using it for end-to-end smoke tests.pyrightconfig.jsonto the sample code repo for Pyright to find thebase,coreandgenpackages. Maybe there are better solutions.OrchestrationServiceclient is created for each orchestration request. How should the correct cleanup look like (for example with regard to theclose_http_connectionmethod, which only closes the sync client)?